home *** CD-ROM | disk | FTP | other *** search
/ .net 2002 March / DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin / pc / PC Software / free_browsing / DavesQckSearchDbar3-14 / dqsd.exe / src / DQSDTools / DQSDTools.cpp next >
C/C++ Source or Header  |  2002-07-18  |  3KB  |  113 lines

  1. // DQSDTools.cpp : Implementation of DLL Exports.
  2.  
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include "DQSDTools.h"
  6.  
  7. #include "DQSDTools_i.c"
  8. #include "KeyboardHook.h"
  9. #include "Launcher.h"
  10. #include "MenuBuilder.h"
  11.  
  12. #ifdef _MERGE_PROXYSTUB
  13. extern "C" HINSTANCE hProxyDll;
  14. #endif
  15.  
  16. CComModule _Module;
  17.  
  18. BEGIN_OBJECT_MAP(ObjectMap)
  19. OBJECT_ENTRY(CLSID_Launcher, CLauncher)
  20. OBJECT_ENTRY(CLSID_MenuBuilder, CMenuBuilder)
  21. END_OBJECT_MAP()
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // DLL Entry Point
  25.  
  26. extern "C"
  27. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  28. {
  29.     lpReserved;
  30. #ifdef _MERGE_PROXYSTUB
  31.     if (!PrxDllMain(hInstance, dwReason, lpReserved))
  32.         return FALSE;
  33. #endif
  34.     if (dwReason == DLL_PROCESS_ATTACH)
  35.     {
  36.         _Module.Init(ObjectMap, hInstance, &LIBID_DQSDTOOLSLib);
  37.         DisableThreadLibraryCalls(hInstance);
  38.  
  39.         ATLTRACE("DQSDTools loading\n");
  40.     }
  41.     else if (dwReason == DLL_PROCESS_DETACH)
  42.     {
  43.         _Module.Term();
  44.         ATLTRACE("DQSDTools unloading\n");
  45.     }
  46.     return TRUE;    // ok
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Used to determine whether the DLL can be unloaded by OLE
  51.  
  52. STDAPI DllCanUnloadNow(void)
  53. {
  54.     ATLTRACE("DQSD: DllCanUnloadNow called (lockcount %d)\n", _Module.GetLockCount());
  55.  
  56. #ifdef _MERGE_PROXYSTUB
  57.     if (PrxDllCanUnloadNow() != S_OK)
  58.     {
  59.  
  60.     }
  61. #endif
  62.  
  63.     if(_Module.GetLockCount()==0)
  64.     {
  65.         ATLTRACE("DQSD: DllCanUnloadNow returns S_OK\n");
  66.         return S_OK;
  67.     }
  68.     else
  69.     {
  70.         ATLTRACE("DQSD: DllCanUnloadNow returns S_FALSE\n");
  71.         return S_FALSE;
  72.     }
  73. }
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // Returns a class factory to create an object of the requested type
  77.  
  78. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  79. {
  80. #ifdef _MERGE_PROXYSTUB
  81.     if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  82.         return S_OK;
  83. #endif
  84.     return _Module.GetClassObject(rclsid, riid, ppv);
  85. }
  86.  
  87. /////////////////////////////////////////////////////////////////////////////
  88. // DllRegisterServer - Adds entries to the system registry
  89.  
  90. STDAPI DllRegisterServer(void)
  91. {
  92. #ifdef _MERGE_PROXYSTUB
  93.     HRESULT hRes = PrxDllRegisterServer();
  94.     if (FAILED(hRes))
  95.         return hRes;
  96. #endif
  97.     // registers object, typelib and all interfaces in typelib
  98.     return _Module.RegisterServer(TRUE);
  99. }
  100.  
  101. /////////////////////////////////////////////////////////////////////////////
  102. // DllUnregisterServer - Removes entries from the system registry
  103.  
  104. STDAPI DllUnregisterServer(void)
  105. {
  106. #ifdef _MERGE_PROXYSTUB
  107.     PrxDllUnregisterServer();
  108. #endif
  109.     return _Module.UnregisterServer(TRUE);
  110. }
  111.  
  112.  
  113.